package com.dsbj.icardservice.controller;


import com.dsbj.icardservice.entity.Reservation;
import com.dsbj.icardservice.service.ReservationService;
import com.dsbj.starter.redis.utils.RedisHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisKeyValueTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private RedisHelper redisHelper;

    @Autowired
    private ReservationService reservationService;

    @RequestMapping("/getReservationList")
    public List<Reservation> getAllReservation() {
        return reservationService.getAllRecords();
    }

    @RequestMapping("/getReservationById")
    public List<Reservation> getReservationById(String id) {
        return reservationService.getReservationById(id);
    }

    @RequestMapping("/getRedisValueByKey")
    public String getRedisValueByKey(String key) {
        return (String) redisHelper.get(key);
    }

    @RequestMapping("/setRedisValue")
    public String setRedisValue(String key,String value) {
        redisHelper.set(key,value);
        return "SUCCESS";
    }


}
